import type { VxeGridProps } from '#/adapter/vxe-table';

import { DictEnum } from '@vben/constants';

import { getDictOptions } from '#/utils/dict';
import { renderDictTags } from '#/utils/render';

export const columns: VxeGridProps['columns'] = [
  {
    title: '序号',
    type: 'seq',
    width: 100,
  },
  {
    field: 'productName',
    title: '产品名称',
  },
  {
    field: 'messageType',
    title: '推送消息类型',
    slots: {
      default: ({ row }) => {
        if (!row.messageType) {
          return '无';
        }
        return renderDictTags(
          row.messageType.split(','),
          getDictOptions(DictEnum.IOT_MESSAGE_TYPE),
          false,
          4,
        );
      },
    },
  },
  {
    field: 'action',
    fixed: 'right',
    slots: { default: 'action' },
    title: '操作',
    resizable: false,
    width: 'auto',
  },
];
